package LeetCode;

import java.util.Scanner;

public class Main026 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入数组长度");
        int size = sc.nextInt();
        int[] nums = new int[size];
        for (int i = 0; i < nums.length; i++) {
            int a = sc.nextInt();
            nums[i] = a;
        }

        System.out.println(removeDuplicates(nums));
    }
    public static int removeDuplicates(int[] nums) {
        if(nums == null || nums.length == 0){
            return 0;
        }
        int count = 0;
        for (int i = 1; i < nums.length; i++) {
            if (nums[count] != nums[i]){
                nums[count] = nums[i];
            } else {
                count++;
                nums[count]=nums[i];
            }
        }
        return count+1;
    }
}
